// 引入mysql的配置文件
const db = require('../../db.config');

// 引入sequelize对象
const Sequelize = db.sequelize;

const fieldMap = Sequelize.import('../../schema/map/classifyFieldMap')

fieldMap.sync({force: false}); // 自动创建表

class fieldMapModule {
  /**
   * 存枚举
   */
  static async setMap(key, value, content) {
    fieldMap.create({
      key,
      value,
      content
    })
  }

  /**
   * 取枚举
   */
  static async getMap(where) {
    return await fieldMap.findAll({
      raw: true,
      where
    })
  }
  
  /**
   * 删枚举
   */
  static async deleteMap(where) {
    await fieldMap.destroy({
      where
    })
  }
}

module.exports = fieldMapModule